//
//  MyHeaderView.m
//  LazyCat
//
//  Created by zhanshu on 15/9/7.
//  Copyright (c) 2015年 zhanshu. All rights reserved.
//

#import "MyHeaderView.h"
#import "LoginViewController.h"
#import "MyMessViewController.h"
#import "Html5ViewController.h"

@implementation MyHeaderView
- (void)awakeFromNib {
    CGFloat width = ScreenWidth/3;
    
    _headerImg.layer.cornerRadius = _headerImg.width/2;
    _headerImg.layer.masksToBounds = YES;
    
    [_myAttentionBtn setHitTestEdgeInsets:UIEdgeInsetsMake(0, -(width-_myAttentionBtn.width)/2, 0, -(width-_myAttentionBtn.width)/2)];
    [_myColloctBtn setHitTestEdgeInsets:UIEdgeInsetsMake(0, -(width-_myColloctBtn.width)/2, 0, -(width-_myColloctBtn.width)/2)];
    [_myFootprintBtn setHitTestEdgeInsets:UIEdgeInsetsMake(0, -(width-_myFootprintBtn.width)/2, 0, -(width-_myFootprintBtn.width)/2)];
}
- (IBAction)userMess:(UIButton *)sender {
    if ([AppData share].doLogin) {
        MyMessViewController *myMess = [[MyMessViewController alloc] init];
        [self.viewController.navigationController pushViewController:myMess animated:YES];
    }else {
        LoginViewController *login = [[LoginViewController alloc] init];
        [self.viewController presentViewController:login animated:YES completion:^{
        
        }];
    }
}
- (IBAction)btnClick:(UIButton *)sender {
    NSString *url = @"";
    NSString *titleName = @"";
    if (![AppData share].doLogin) {
        LoginViewController *login = [[LoginViewController alloc] init];
        [self.viewController presentViewController:login animated:YES completion:^{
            
        }];
        return;
    }
    if (sender.tag == 100) {
        //我的关注
        url = [NSString stringWithFormat:MyFocusList,[AppData share].username,[AppData share].lng,[AppData share].lat,[Utils md5SignStr]];
        titleName = @"我的关注";
    }else if (sender.tag == 101) {
        //我的收藏
        url = [NSString stringWithFormat:MyCollection,[AppData share].username,[AppData share].lng,[AppData share].lat,[Utils md5SignStr]];
        titleName = @"我的收藏";
    }else if (sender.tag == 102) {
        //足迹
        url = [NSString stringWithFormat:MyFootLine,[AppData share].username,[AppData share].lng,[AppData share].lat,[Utils md5SignStr]];
        titleName = @"足迹";
    }
    Html5ViewController *html5 = [[Html5ViewController alloc] init];
    html5.requestUrl = url;
    html5.titleStr = titleName;
    [self.viewController.navigationController pushViewController:html5 animated:YES];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
